﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace GUI
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Login : Window
    {
        public Login()
        {
            InitializeComponent();
            VisMekanikere();
            Controller.Auth a = Controller.Auth.ResetInstance();
        }

       

       

        private void Luk_Click_1(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (comboBox1.SelectedIndex == 2)
                MekcomboBox.Visibility = Visibility.Visible;
            else
                MekcomboBox.Visibility = Visibility.Collapsed;
                
        }

        private void VisMekanikere()
        {
            List<KeyValuePair<int, string>> Mekanikere = Data.Mekaniker_DB.HentAlleMekanikere();

            MekcomboBox.DisplayMemberPath = "Value";
            MekcomboBox.SelectedValuePath = "Key";

            MekcomboBox.ItemsSource = Mekanikere;
        }

        private void button1_Click_1(object sender, RoutedEventArgs e)
        {

            Controller.Auth a = Controller.Auth.GetInstance();

            if (comboBox1.SelectedIndex > -1)
            {
                a.LoggetInd = true;

                if (comboBox1.SelectedIndex == 0)
                    a.administration = true;
                if (comboBox1.SelectedIndex == 1)
                    a.VaerkFoerer = true;
                if (comboBox1.SelectedIndex == 2)
                {
                    a.Mekaniker = true;
                    a.MekanikerNr = int.Parse(MekcomboBox.SelectedValue.ToString());

                }

                Close();
            }
            
        }
    }
}
